import Koa from 'koa';
import { routes } from './common/router';
import errorHandle from './common/middleware/errorHandle';
import logHandle from './common/middleware/logHandle';

async function main() {
  const app = new Koa();
  app.use(logHandle);
  app.use(errorHandle);
  await routes(app);

  const port = process.env.PORT || 3000;

  app.listen(port);
  console.log(`app start on port ${port}`);
}
main().catch((e) => {
  console.error(e);
});
